<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 选择根元素 */
    :root {
      border: 10px dotted gray;
    }
    html {
      border: 10px solid skyblue;
    }
    body {
      border: 10px solid cyan;
    }

    /* 选择空元素 */
    p {
      border: 1px solid #ccc;
    }
    p:empty {
      display: none;
    }

    /* 选择第一种和最后一种元素 */
    .test a:first-of-type {
      color: red;
    }
  </style>
</head>
<body>
  <p>ddddddd</p>
  <p></p>

  <div class="test">
    <div>
      <span>ddd</span>
      <a href="">aaa</a>
      <p>sss</p>
    </div>
    <a href="">ggg</a>
  </div>
</body>
</html>